﻿select 
	  h.id
	, h.pos
	, h.cash_id
	, h.local_number
	, h.global_number
	, h.date as dateb
	, f.date as datee
	, f.result
	, s.number as shift_open
	, l.user_name 
from trm_out_receipt_header h 
	left join trm_out_receipt_footer f on (h.cash_id=f.cash_id and h.id=f.id)
	left join trm_out_shift_open s on h.cash_id=s.cash_id and h.shift_open=s.id 
	inner join trm_out_login l ON (l.id=s.login)and(l.cash_id=h.cash_id)
--where
	--    ( h.date >= '".$_POST["datebeg"]."' )
	--and ( h.date < ADDDATE('".$_POST["dateend"]."',INTERVAL 1 DAY) )
	--and ( f.result=".$_POST["type"]." )
order by h.date,h.shift_open
